#pragma once
#include <windows.h>

class Stopwatch
{
private:
    double PCFreq;
    __int64 CounterStart;

public:
    Stopwatch()
    {
        LARGE_INTEGER li;
        if(!QueryPerformanceFrequency(&li))
            throw std::exception("QueryPerformanceFrequency failed");
        PCFreq = double(li.QuadPart)/1000.0;
        Start();
    }

    void Start()
    {
        LARGE_INTEGER li;
        QueryPerformanceCounter(&li);
        CounterStart = li.QuadPart;
    }

    double Milliseconds()
    {
        LARGE_INTEGER li;
        QueryPerformanceCounter(&li);
        return double(li.QuadPart-CounterStart)/PCFreq;
    }

};
